@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo, info: Option[Any])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main("Danger Zone", Some(repository)){
  @gitbucket.core.html.menu("settings", repository){
    @gitbucket.core.settings.html.menu("danger", repository){
      @gitbucket.core.helper.html.information(info)
      <div class="panel panel-default">
        <div class="panel-heading strong">Danger Zone</div>
        <div class="panel-body">
          <form id="gc-form" method="post" action="@helpers.url(repository)/settings/gc">
            <fieldset class="form-group">
              <label class="strong">Garbage collection</label>
              <div>
                Run garbage collection for this git repository immediately.
                <input type="submit" class="btn btn-danger pull-right" value="Garbage collection"/>
              </div>
            </fieldset>
          </form>
          @if(context.settings.basicBehavior.repositoryOperation.rename || context.loginAccount.get.isAdmin){
            <form id="rename-form" method="post" action="@helpers.url(repository)/settings/rename" validate="true" autocomplete="off">
              <fieldset class="border-top form-group">
                <label class="strong">Rename repository</label>
                <div>
                  Rename this repository. This will make the current URL unavailable.
                  <div class="pull-right">
                    <input type="text" name="repositoryName" id="repositoryName" class="form-control" style="width: 200px; display: inline; vertical-align: middle;" value="@repository.name" aria-label="Repository name"/>
                    <input type="submit" class="btn btn-danger" value="Rename"/>
                    <div>
                      <span id="error-repositoryName" class="error"></span>
                    </div>
                  </div>
                </div>
              </fieldset>
            </form>
          }
          @if(context.settings.basicBehavior.repositoryOperation.transfer || context.loginAccount.get.isAdmin){
            <form id="transfer-form" method="post" action="@helpers.url(repository)/settings/transfer" validate="true" autocomplete="off">
              <fieldset class="border-top form-group">
                <label class="strong">Transfer Ownership</label>
                <div>
                  Transfer this repository to another user or to group.
                  <div class="pull-right">
                    @gitbucket.core.helper.html.account("newOwner", 200, true, true)
                    <input type="submit" class="btn btn-danger" value="Transfer"/>
                    <div>
                      <span id="error-newOwner" class="error"></span>
                    </div>
                  </div>
                </div>
              </fieldset>
            </form>
          }
          @if(context.settings.basicBehavior.repositoryOperation.delete || context.loginAccount.get.isAdmin){
            <form id="delete-form" method="post" action="@helpers.url(repository)/settings/delete">
              <fieldset class="border-top form-group">
                <label class="strong">Delete repository</label>
                <div>
                  Permanently delete this repository. This cannot be undone.
                  <input type="submit" class="btn btn-danger pull-right" value="Delete this repository"/>
                </div>
              </fieldset>
            </form>
          }
        </div>
      </div>
    }
  }
}
<script>
$(function(){
  $('#delete-form').submit(function(){
    return confirm('Once you delete a repository, there is no going back.\nAre you sure?');
  });
  $('#rename-form').submit(function(){
    if($('#rename-form').data('validated') === true){
      return confirm('Rename this repository as you entered. The current URL will be unavailable.\nAre you sure?');
    } else {
      return true;
    }
  });
  $('#transfer-form').submit(function(){
    if($('#transfer-form').data('validated') === true){
      return confirm('Transfer to the repository owner you entered.\nAre you sure?');
    } else {
      return true;
    }
  });
  $('#gc-form').submit(function(){
    return confirm('The garbage collection may take a long time.\nDo you want to execute it?');
  });
});
</script>
